#!coding=utf-8
from django.db import models
from mptt.models import MPTTModel, TreeForeignKey
import datetime
import time


class WMenu(MPTTModel):
    """
    微信菜单
    """
    WTYPE_CHOICES = (('click',u'点击'),
                     ('view',u'查看',),
                     ('parent',u'父菜单'))
    
    parent = TreeForeignKey('self',verbose_name=u'父菜单', null=True, blank=True, related_name='children')
    wtype = models.CharField(u'菜单类型',max_length=10,choices=WTYPE_CHOICES,help_text=u'类型为"父菜单",则必须要有子菜单')
    name = models.CharField(u'菜单名称',max_length=20)
    value = models.CharField(u'值',help_text=u'类型为"点击",则输入键码，如果类型为"查看",则输入url',max_length=256,null=True,blank=True)
    position = models.IntegerField(u'顺序')
    
    def __unicode__(self):
        return self.name
    
    class Meta:
        verbose_name=u"微信菜单"
        verbose_name_plural=u"微信菜单管理"

    class MPTTMeta:
        order_insertion_by = ['position']

class User(models.Model):
    SEX_CHOICES = (('1',u'男'),
                     ('0',u'女'),
                     ('2',u'未提交'))
    openid = models.CharField(max_length=50, blank=False)
    nickname=models.CharField(u'昵称',max_length=50,blank=True)
    sex=models.CharField(u'性别',choices=SEX_CHOICES,default='2',max_length=10,blank=True)
    telephone=models.CharField(u'手机号',max_length=11,blank=True)
    is_active=models.BooleanField(u'是否验证',default=False)
    active_at = models.CharField(u'最新手机验证时间',max_length=50,blank=True)
    latitude=models.CharField(u'经度',max_length=50,blank=True)
    longitude=models.CharField(u'纬度',max_length=50,blank=True)
    precision=models.CharField(u'精度',max_length=50,blank=True)
    modify_at = models.CharField(u'最新经纬度时间',max_length=50,blank=True)
    city=models.CharField(u'城市',max_length=100,blank=True)
    province=models.CharField(u'省份',max_length=100,blank=True)
    headimgurl=models.URLField(u'用户头像图片地址',blank=True)
    subscribe_time=models.CharField(u'关注公众账号时间',max_length=50,blank=True)
    def __unicode__(self):  
       return '%s'%(self.openid)

    class Meta:
        verbose_name=u"用户菜单"
        verbose_name_plural=u"用户菜单管理"













        
        